﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.Net.DataStructures
{
    public class TypeValueMapper<TValue>
    {
        readonly List<Tuple<Type, TValue>> _mapping = new List<Tuple<Type,TValue>>();

        public void AddMapping<T>(TValue value)
        {
            _mapping.Add(Tuple.New(typeof(T), value));
        }

        public TValue GetValue(object obj)
        {
            return _mapping.Single(m => m.Value1.IsInstanceOfType(obj)).Value2;
        }
    }
}
